<template>
	<scroll ref="mescrollRef" @init="mescrollInit" :down="downOption"  @down="downCallback" :up="upOption" @up="upCallback" @emptyclick="emptyClick">
		<stop isBack>
			<view slot="content">维修任务</view>
		</stop>
		<view class="bcf padlr3 padtb2 bdtso">
			<search class="fs8 tac" placeholder="故障 \ 单号 \ 设备名称 \ 编码 \ 型号"  v-model="search" @search="doSearch"></search>
		</view>
		<view class="flrc bcf pad3 bdtso bdbso fs8">
			<!-- <view class="flex1"><scondition @input="reload()" model="MachineBreakStatus" v-model="where.eq.status" label="订单状态"></scondition></view> -->
			<view class="flex1"><scondition @input="reload" model="MachineBreakEmergency" v-model="where.eq.emergency" label="紧急程度"></scondition></view>
			<view class="flex1"><scondition @input="reload" model="MachineBreakLevel" v-model="where.eq.level" label="故障等级"></scondition></view>
		</view>
		<view class="padlr3">
			
			<view class="bcf pos-r mart3 round3 shadow ofh"  @tap="mySlide(index)" v-for="item,index in data" :key="item.id">
				<breaks class="mar2" :item="item" :showAngle="false"></breaks>
				<sslide ref="mySlideBox">
					<view class="bg-gradual-orange flex1 flcc">
							<view class="w100 flex1 flcc pos-r padlr5" @tap="goto('/pages/machine/break_order_info?id='+item.id)">查看<ripple></ripple></view>
							<view class="w100 flex1 flcc pos-r padlr5 bdtso" @tap="getIt(item.id)">接下<ripple></ripple></view>
					</view>
				</sslide>
				<!-- <view class="pos-a t0 b0 r0 bg-orange flcc flex-fill " 
				style="width: 30vw;transform: translateX(98%)"
				:class="[curActionId == item.id?'animation-slide-right':'']"
				>
					
				</view> -->
			</view>
		</view>
		<loading :loading="myIsLoading"></loading>
	</scroll>
</template>

<script>
	import MescrollMixin from "@/components/mescroll-uni/mescroll-mixins.js";
	import breaks from '../../templete/machine/machine_break_list_com.vue'
	import List from '../../assets/js/list.js'
	
	export default {
		mixins:[MescrollMixin],
		components:{breaks},
		data() {
			let status = this.$com.getLocData('DEFAULT_BREAK_ORDER_STATUS_ID')
			status = this.isbool(status)?status:0
			let list = new List()
			return {
				list,
				where:{
					eq:{
						status:status,
						emergency:'',
						level:'',
					}
				},
				search:"",
				data:[],
				curActionId:0
			}
		},
		methods: {
			reload(text){
				this.log(text)
				this.showLoading()
				this.list
				.setData({_order:{id:"DESC"},_where:this.where,_search:this.search})
				.reload()
			},
			doSearch(){
				this.showLoading()
				this.list
				.setData({_order:{id:"DESC"},_where:this.where,_search:this.search})
				.reload()
			},
			showAction(id){
				this.curActionId = this.curActionId == id?0:id
			},
			getIt(id){//接取任务
				this.log(id)
				//创建数据
				let data = {
					breakOrder:'/api_/machine_breaks/' + id,
				}
				this.showLoading()
				this.$api.post('/api/machineFixOrders',data,(res)=>{
					this.log(res)
					this.clearLoading()
					this.reload("333")
					if(res.s == 1){
						this.goto('/pages/machine/fix_order_confirm?id=' + res.d.id)
					}
					
				})
			}
		},
		mounted(){
			this.list.initMescroll(this)
			.setUrl('/api/machineBreaks')
			.setData({
				_order:{id:"DESC"},
				_where:this.where,
				_search:this.search,
			})
			.setCbFunc(res=>{
				this.data = res
				this.clearLoading()
			}).reload()
		},
		onShow() {
			this.list.reload("onShow reload")
		},
		watch:{
		}
	}
</script>

<style>

</style>
